<template>
  <div>
    <FormPanel ref="formPanel" :list="formList" @formChange="formChangeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="120" />

    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <multiuse-button type="primary" :click="printHandle">打 印</multiuse-button>
      <el-button @click="closeDrawer">关 闭</el-button>
    </div>

    <!-- 打印 -->
    <div v-if="isPrint && verifyType == '60861004'">
      <BasePrint ref="printPick" :data="printData" template="RebateManage/RebateStatementQueryMonth" />
    </div>
    <div v-if="isPrint && verifyType != '60861004'">
      <BasePrint ref="printPick" :data="printData" template="RebateManage/RebateStatementQuery" />
    </div>
  </div>
</template>
<script>
import moment from 'moment';
import { dictionary } from '@/utils/dictMixin';
import { queryById } from '@/api/dealerFinance/RebateManage/RebateStatementQuery';

export default {
  mixins: [dictionary],
  props: ['rowData'],

  data() {
    this.saveData = null;
    return {
      formList: this.createdFrom(),
      list: [],
      isPrint: false,
      printData: {},
      verifyType: ''
    };
  },
  created() {
    this.init();
  },
  methods: {
    async init() {
      const res = await queryById(this.rowData.id);
      if (res.resultCode == 200) {
        this.formList.map(x => {
          x.initialValue = res.data[x.fieldName];
        });
        this.verifyType = res.data.verifyType;
        this.printData = res.data;
        this.printData.verifyResult = this.createDictText(res.data.verifyResult, '6085');
      }
    },
    formChangeHandle(val) {
      this.saveData = val;
    },
    // 打印
    async printHandle() {
      this.isPrint = true;

      this.$nextTick(() => {
        this.$refs.printPick.EXCUTE_PRINT();
      });
    },
    closeDrawer() {
      this.$emit('close');
    },

    createdFrom() {
      return [
        {
          type: 'INPUT',
          label: '对账单号',
          fieldName: 'verifyNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '账单名称',
          fieldName: 'verifyName',
          placeholder: '',
          disabled: true
        },

        {
          type: 'SELECT',
          label: '对账分类',
          fieldName: 'verifyType',
          placeholder: '请选择',
          itemList: this.createDictList('6086'),
          disabled: true
        },
        {
          type: 'INPUT',
          label: '经销商代码',
          fieldName: 'dealerCode',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'dealerName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'DATE',
          label: '生成日期',
          fieldName: 'createdAt',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '整车款余额',
          fieldName: 'vehicleAccountAmount',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '差异金额',
          fieldName: 'vehicleAccountDifferences',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '调整后金额',
          fieldName: 'vehicleAccountAdjustment',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '整车返利余额',
          fieldName: 'vehicleRebateAmount',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '差异金额',
          fieldName: 'vehicleRebateDifferences',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '调整后金额',
          fieldName: 'vehicleRebateAdjustment',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '备件款余额',
          fieldName: 'partAccountAmount',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '差异金额',
          fieldName: 'partAccountDifferences',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '调整后金额',
          fieldName: 'partAccountAdjustment',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '备件返利余额',
          fieldName: 'partRebateAmount',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '差异金额',
          fieldName: 'partRebateDifferences',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '调整后金额',
          fieldName: 'partRebateAdjustment',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '建店保证金余额',
          fieldName: 'depositAmount',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '差异金额',
          fieldName: 'depositDifferences',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '调整后金额',
          fieldName: 'depositAdjustment',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '其他类应收款项',
          fieldName: 'otherInAmount',
          placeholder: '',
          disabled: true
        },

        {
          type: 'INPUT',
          label: '差异金额',
          fieldName: 'otherInDifferences',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '调整后金额',
          fieldName: 'otherInAdjustment',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '其他类应付款项',
          fieldName: 'otherOutAmount',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '差异金额',
          fieldName: 'otherOutDifferences',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '调整后金额',
          fieldName: 'otherOutAdjustment',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '账户资金所属公司',
          fieldName: 'orgCompanyName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '对账结果',
          fieldName: 'verifyResult',
          placeholder: '',
          itemList: this.createDictList('6085'),
          disabled: true
        },
        {
          type: 'INPUT',
          label: '经销商反馈差异金额',
          fieldName: 'feedbackAmountDesc',
          placeholder: '',
          selfCols: 3,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '经销商反馈差异说明',
          fieldName: 'feedbackExplainDesc',
          placeholder: '',
          selfCols: 3,
          disabled: true
        },
        {
          type: 'INPUT',
          label: '审批意见',
          fieldName: 'checkDesc',
          placeholder: '',
          selfCols: 3,
          disabled: true
        }
      ];
    }
  }
};
</script>
